package cn.tangshh.universal.security.entity;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;

import java.util.Objects;

/**
 * 基础权限信息
 *
 * @author Tang
 * @version v1.0
 * @since 2024/10/14
 */
@Data
@Schema(title = "权限信息抽象类")
public abstract class BasicGrantedAuthority implements GrantedAuthority {

    @Schema(title = "权限")
    private String authority;

    @Schema(title = "权限说明")
    private String description;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof BasicGrantedAuthority that)) return false;
        return Objects.equals(authority, that.authority);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(authority);
    }
}